
<!--login_page_identity-->
<!--以上文件注释不可去掉，校验文件首页用,详见base.js的jquery.fn.load-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="baidu_union_verify" content="804240c1607916fb8a8b98c6bcd2cfdb">
    <meta name="keywords" content="AdminLTE,AdminEAP,AdminLTE框架">
    <meta name="description" content="基于AdminLTE的快速开发框架,让web开发更简单">
    <meta property="wb:webmaster" content="4f7a2b4a630250fe" />
    <title>AdminL | 登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!--icon-->
    <link rel="shortcut icon" type="image/x-icon" href="/resources/common/favicon.ico" media="screen"/>
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="css/red.css">
    <link rel="stylesheet" href="css/bootstrap-validator.css"/>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <!--<script src="/resources/common/libs/html5shiv/html5shiv.min.js"></script>-->
    <!--<script src="/resources/common/libs/respond/respond.min.js"></script>-->
    <![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#"><b>Admin</b>Luwak</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">测试账号 test/bill</p>

        <form action="/index" method="post" id="login-form">
            <div class="form-group has-feedback">
                <input type="text" class="form-control"  name="userName" placeholder="请输入登录邮箱/登录名">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" class="form-control" name="password" placeholder="请输入密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox" name="rememberMe"> 记住用户
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-6">
                    <div class="checkbox pull-right">
                        <a href="#">忘记密码</a>
                        <span>&nbsp;/&nbsp;</span>
                        <a href="/register" class="text-center">注册</a>
                    </div>
                </div>
                <!-- /.col -->
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <button type="submit" class="btn btn-danger btn-block btn-flat">登 录</button>
                </div>
            </div>
        </form>


        <div class="social-auth-links" style="margin-bottom: 0px;">
            <div class="row">
                <div class="col-xs-5">
                    <div class="text-left" style="margin-top: 5px;">快速登录</div>
                </div>
                <div class="col-xs-7">
                    <div class="text-right">
                        <!--<a class="btn btn-social-icon btn-primary"><i class="fa fa-qq"></i></a>
                        <a class="btn btn-social-icon btn-success"><i class="fa fa-wechat"></i></a>
                        <a class="btn btn-social-icon btn-warning"><i class="fa fa-weibo"></i></a>
                        <a class="btn btn-social-icon btn-info"><i class="fa fa-github"></i></a>-->
                        <a class="btn btn-social-icon btn-info" href="https://github.com/login/oauth/authorize?client_id=665051f90d4b055f5ab6&redirect_uri=http%3A%2F%2Fwww.admineap.com%2Foauth%2Fgithub%2Fcallback&state=8da338efdb8c11e6a8f82c11d0e2fa3f"><i class="fa fa-github"></i></a>
                    </div>
                </div>
            </div>
            <!-- /.social-auth-links -->
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
</div>
<!-- jQuery 2.2.3 -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="plugins/icheck.min.js"></script>
<!-- bootstrap-validator-->
<script src="plugins/bootstrap-validator.js"></script>
<!--login.js-->
<!--<script src="/resources/common/js/login.js"></script>-->
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-red',
            radioClass: 'iradio_square-red',
            increaseArea: '20%' // optional
        });

        fillbackLoginForm();
        $("#login-form").bootstrapValidator({
            message:'请输入用户名/密码',
            submitHandler:function (valiadtor,loginForm,submitButton) {
                rememberMe($("input[name='rememberMe']").is(":checked"));
                valiadtor.defaultSubmit();
            },
            fields:{
                userName:{
                    validators:{
                        notEmpty:{
                            message:'登录邮箱名或用户名不能为空'
                        }
                    }
                },
                password:{
                    validators:{
                        notEmpty:{
                            message:'密码不能为空'
                        }
                    }
                }
            }
        });

    });



    //使用本地缓存记住用户名密码
    function rememberMe(rm_flag){
        //remember me
        if(rm_flag){
            localStorage.userName=$("input[name='userName']").val();
            localStorage.password=$("input[name='password']").val();
            localStorage.rememberMe=1;
        }
        //delete remember msg
        else{
            localStorage.userName=null;
            localStorage.password=null;
            localStorage.rememberMe=0;
        }
    }

    //记住回填
    function fillbackLoginForm(){
        if(localStorage.rememberMe&&localStorage.rememberMe=="1"){
            $("input[name='userName']").val(localStorage.userName);
            $("input[name='password']").val(localStorage.password);
            $("input[name='rememberMe']").iCheck('check');
            $("input[name='rememberMe']").iCheck('update');
        }
    }

    /**
     * Created by billJiang on 2017/1/12.
     * 登录异常信息显示
     */

    function LoginValidator(config) {
        this.code = config.code;
        this.message = config.message;
        this.userName = config.userName;
        this.password = config.password;
        this.initValidator();
    }

    //0 未授权 1 账号问题 2 密码错误  3 账号密码错误
    LoginValidator.prototype.initValidator = function () {
        if (!this.code)
            return;
        if(this.code==0){
            this.addPasswordErrorMsg();
        }else if(this.code==1){
            this.addUserNameErrorStyle();
            this.addUserNameErrorMsg();
        }else if(this.code==2){
            this.addPasswordErrorStyle();
            this.addPasswordErrorMsg();
        }else if(this.code==3){
            this.addUserNameErrorStyle();
            this.addPasswordErrorStyle();
            this.addPasswordErrorMsg();
        }
        return;
    }

    LoginValidator.prototype.addUserNameErrorStyle = function () {
        this.addErrorStyle(this.userName);
    }

    LoginValidator.prototype.addPasswordErrorStyle = function () {
        this.addErrorStyle(this.password);
    }

    LoginValidator.prototype.addUserNameErrorMsg = function () {
        this.addErrorMsg(this.userName);
    }

    LoginValidator.prototype.addPasswordErrorMsg = function () {
        this.addErrorMsg(this.password);
    }


    LoginValidator.prototype.addErrorMsg=function(field){
        $("input[name='"+field+"']").parent().append('<small  data-bv-validator="notEmpty" data-bv-validator-for="'+field+'" class="help-block">' + this.message + '</small>');
    }

    LoginValidator.prototype.addErrorStyle=function(field){
        $("input[name='" + field + "']").parent().addClass("has-error");
    }
</script>
</body>
</html>
